package com.ruoyi.ctcx.controller;

import com.ruoyi.common.constant.PermissonConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.ctcx.domain.ro.InsuranceParam;
import com.ruoyi.system.service.ISysDeptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * web层通用数据处理
 * 
 * @author ruoyi
 */
public class BaseControllerExt extends BaseController
{
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ISysDeptService deptService;

    /**
     * 获取登录部门id
     */
    public void initDeptId(InsuranceParam insuranceParam)
    {

        Long deptId = getLoginUser().getDeptId();

        SysDept sysDept = deptService.selectDeptById(deptId);

        Long parentId = sysDept.getParentId();

        //经纪/代理公司,自家看自家
        if (PermissonConstants.JJDLDEPTID.equals(parentId))
        {
            insuranceParam.setProxyId(deptId.toString());
        }
        //保险公司,自家看自家
        else if(PermissonConstants.BAOXIANDEPTID.equals(parentId))
        {
            insuranceParam.setBaoxianId(deptId.toString());
        }
    }
}
